home *** CD-ROM | disk | FTP | other *** search
/ Aminet 5 / Aminet 5 - March 1995.iso / Aminet / dev / misc / LEDA_gene.lha / LEDA-3.1c-generic / man / vector.tex < prev    next >
Encoding:
Text File  |  1994-08-05  |  2.2 KB  |  78 lines

  1. \bigskip
  2. \bigskip
  3. {\magonebf  2.3 Real-Valued Vectors (vector)}
  4.  
  5. An instance of the data type $vector$ is a vector of real variables.
  6.  
  7. \def\name{$vector$}
  8. \def\type{$vector$}
  9.  
  10. \bigskip
  11. {\bf 1. Creation}
  12.  
  13. a) \create v (int\ d)
  14.  
  15. b) \create v (double\ a,\ double\ b)
  16.  
  17. c) \create v (double\ a,\ double\ b,\ double\ c)
  18.  
  19.  
  20. creates an instance $v$ of type $vector$; $v$ is initialized to the zero
  21. vector of dimension $d$ (variant a), the two-dimensional vector $(a,b)$
  22. (variant b) or the three-dimensional vector $(a,b,c)$ (variant c).
  23.  
  24.  
  25. \bigskip
  26. {\bf 2. Operations on a vector v}
  27.  
  28. \medskip
  29. \+\cleartabs & \hskip 2.5truecm & \hskip 5truecm &\cr
  30. \+\op int   dim {}         
  31.                            {returns the dimension of $v$.}
  32. \smallskip
  33. \+\op double  length {}      
  34.                            {returns the Euclidean length of $v$}
  35. \smallskip
  36. \+\op double  angle {vector\ w}  
  37.                            { returns the angle between $v$ and $w$.}
  38. \medskip
  39. \+\opa double\&  {int\ i}           
  40.                            {returns $i$-th component of $v$.}
  41. \+\nop                     {\precond $0\le i \le v$.dim()$-$1.}
  42. \smallskip
  43. \+\opb vector       +  {v_1}
  44.                            {Addition}
  45. \+\nop                     {\precond $v$.dim() = $v_1$.dim().}
  46. \smallskip
  47. \+\opb vector    -  {v_1}
  48.                            {Subtraction}
  49. \+\nop                     {\precond $v$.dim() = $v_1$.dim().}
  50. \smallskip
  51. \+\opb double      *  {v_1}
  52.                            {Scalar multiplication}
  53. \+\nop                     {\precond $v$.dim() = $v_1$.dim().}
  54. \smallskip
  55. \+\opb vector    *  {r}
  56.                            {Componentwise multiplication with double $r$}
  57. \smallskip
  58. \+\opb bool      == {v_1}
  59.                            {Test for equality}
  60. \smallskip
  61. \+\opb bool      != {v_1}
  62.                            {Test for inequality}
  63. \medskip
  64. \+\ops ostream\& << {O}  
  65.                            {writes $v$ componentwise to the output stream $O$}
  66. \smallskip
  67. \+\ops istream\& >> {I}  
  68.                            {reads $v$ componentwise from the input stream $I$}
  69.  
  70.  
  71. \bigskip
  72. {\bf 3. Implementation }
  73. \medskip
  74. Vectors are implemented by arrays of real numbers. All operations on a
  75. vector $v$ take time $O(v.dim())$, except of dim and $[\ ]$ which take constant
  76. time. The space requirement is $O(v.dim())$.
  77.  
  78.